<template>
	<view class="">
		<!-- <u-navbar title="合同文件.pdf" @leftClick="leftClick" :autoback="true"></u-navbar> -->
		<web-view :src="urls"></web-view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				contractFile:'',
				urls:''
			};
		},
		onLoad(option) {
			this.contractFile = 'https://zzn.ahyzg.com/yw6' + option.contractFile;
			this.viewFile();
		},
		methods:{
			leftClick(){
				if (getCurrentPages().length > 1) {
					uni.navigateBack();
				} else {
					uni.switchTab({
						url: '../../pages/index/index'
					})
				}
			},
			viewFile() {
				let that = this;
				uni.request({
					url: this.contractFile,
					method: "GET",
					data: {
						fileType: 'pdf',
					},
					success: (res) => {
						console.log(res,'00')
						// that.url = 'https://zzn.ahyzg.com/yw6' + res.data.data;
						
						uni.downloadFile({
							url: 'https://zzn.ahyzg.com/yw6' + res.data.data,
							success: res => {
								that.urls = res.tempFilePath;
								console.log(res,'==')
								uni.openDocument({
									filePath: res.tempFilePath,
									success: (res) => {
										console.log(res, '文件打开成功');
									}
								})
							}
						})
					
					}
				});
			}
		}
	}
</script>

<style lang="scss" scoped>
	
</style>